<template>
	<view>
		<Info :tableData="tableData" :loading="loading" label="DESCR" value="DESCR_CVAL" />
		
		<!-- 空数据 -->
		<u-empty
			v-if="tableData.length === 0 && !loading" mode="data"
			text="~暂无数据"
			icon="http://cdn.uviewui.com/uview/empty/data.png"
		></u-empty>
	</view>
</template>

<script>
	import Info from '@/components/Repair/Info/index'
	import { mapState } from 'vuex'
	import { checkLogin } from '@/utils/lib'
	import { getCartData } from '@/apis/applyTask'
	
	export default {
		components: {
			Info
		},
		
		computed: {
			...mapState({
				token: state => state.user.token,
				longitude: state => state.user.longitude,
				latitude: state => state.user.latitude,
			})
		},
		
		data() {
			return {
				// 车号
				cartNum: '',
				
				// 表格数据
				tableData: [],
				loading: false,
			}
		},
		
		onShow() {
			checkLogin() // 校验是否登录
			// 获取车辆配置信息
			this.findCartInfos()
		},
		
		onLoad(options) {
			this.cartNum = options.cartNum
			if (options.title) {
				uni.setNavigationBarTitle({
					title: options.title
				})
			}
		},
		
		methods: {
			// 获取车辆配置信息
			findCartInfos() {
				let params = {
					InField: {
						FORKLIFT_NUM: this.cartNum
					},
					OutTable: {
						TB_CONFIG: ["CHARACTERNAME", "DESCR", "CHARACTERVALUE", "DESCR_CVAL"]
					},
					SAPName: "ZSMP_GET_FORKLIFT_CONFIG",
				}
				
				this.loading = true
				
				getCartData(params, this.token, this.longitude + ',' + this.latitude).then(res => {
					this.loading = false
					this.tableData = res.Result.OutTable[0]
				}).catch(err => {
					this.loading = false
				})
			}
		}
	}
</script>

<style>

</style>
